<!DOCTYPE HTML>
<html>

<head>
    <title> 资源文件结构</title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
    <link href="/static/assets/css/bui-min.css" rel="stylesheet" type="text/css"/>
    <link rel="stylesheet" href="/static/bootstrap/css/bootstrap.css"/>
    <link rel="stylesheet" href="/static/plugins/bui/bui.css"/>
    <link rel="stylesheet" href="/static/plugins/layui/css/layui.css" media="all">

    <style type="text/css">
        body{
            background: #EFF3FC;
        }
        html,body,.content{
            height:100%;
        }

{#        .content,#}
{#        #organize {#}
{#            height: 100%;#}
{#        }#}

        ul,
        li {
            list-style: none;
            padding: 0px;
        }

        .content {
            margin-left: 0;
            margin-top: 0;
            width: auto;
            padding: 0px 20px 0 20px;
        }

        #myTabContent {
            height:89%;
        }

        #myTab {
            border-top: 1px solid #EFF3FC;
            border-bottom: 2px solid #EFF3FC;
        }
        .tab-content>div{
            height:100%;
        }
        #organize > div {
            overflow: hidden;
            height: 97%;
            margin-top: 1%;
        }

        #organize .dictory {
            width: 16%;
            float: left;
            border: 1px solid #EFF3FC;
            background: #ffffff;
            height: 100%;
            border-radius: 10px;
        }

        #organize .dictory > div {
            height: 40px;
            padding: 2% 2%;
            border-bottom: 1px solid #EFF3FC;
            line-height: 40px;
        }

        #organize .dictory > div.title {
            text-align: center;
        }

        #organize .dictory ul li {
            height: 30px;
            line-height: 30px;
        }

        #organize .showDictory {
            width: 83%;
            border: 1px solid #EFF3FC;
            float: right;
            height: 100%;
            background: #ffffff;
            border-radius: 10px;
        }

        #organize .showDictory .operationBtn {
            width: 100%;
            padding: 14px;
        }

        #organize .showDictory .showDetail {
            height: 100%;
            width: 100%;
            margin: 0 auto;
            position: relative;
            overflow-y: auto;
        }

        #organize .showDictory .showDetail table {
            width: 95%;
            margin: 0 auto;
            text-align: center;
        }

{#        #organize .showDictory .showDetail table thead tr {#}
{#            background: #EFF3FC;#}
{#        }#}

        #organize .showDictory .showDetail table tr th {
            text-align: center;
        }

        #organize .showDictory .showDetail table tr {
            height: 30px;
        }

        #userMang > div {
            overflow: hidden;
            height: 97%;
            margin-top: 1%;
        }

        #userMang .dictory {
            width: 16%;
            float: left;
            border: 1px solid #EFF3FC;
            height: 99%;
            background: #ffffff;
            border-radius: 10px;
        }

        #userMang .dictory > div {
        {#height: 40px;#} padding: 2% 2%;
            border-bottom: 1px solid #EFF3FC;
        {#line-height: 40px;#}
        }

        #userMang .dictory > div.title {
            text-align: center;
        }

        #userMang .dictory ul li {
            height: 30px;
            line-height: 30px;
        }

        #userMang .showDictory {
            width: 83%;
            border: 1px solid #EFF3FC;
            float: right;
            height: 99%;
            background: #ffffff;
            border-radius: 10px;
        }

        #userMang .showDictory .operationBtn ,#jobRole .showJobList .operationBtn{
            width: 100%;
            padding:14px;
        }

        #userMang .showDictory .showDetail {
            height: 100%;
            width: 100%;
            margin: 0 auto;
            position: relative;
            overflow-y: auto;
        }

        #userMang .showDictory .showDetail table, #jobRole .showJobList .showDetail table{
            width: 95%;
            text-align: center;
            margin: 0 auto;
        }


        #userMang .showDictory .showDetail table tr th {
            text-align: center;
        }

        #userMang .showDictory .showDetail table tr {
            height: 30px;
        }

        #chanceDetail li:first-child input {
            margin-right: 10px;
        }

        #chanceDetail li input {
            margin-right: 14px;
        }

        .table tbody > tr > td {
            border: none;
        }

        .table thead > tr > th {
            border-bottom: 1px solid #ddd;
            border-top: 1px solid #ddd;
            text-align: center;
        }

        .table td {
            text-align: center;
        }

        /* 左侧树 */
        .bui-tree-list {
            border: none;
        }

        .table-content {
            height: 84%;
            overflow: auto;
        }

        .pag {
            border-top: 1px solid #eeeeee;
            margin-left: 1%;
        }

        .layui-laypage .layui-laypage-curr .layui-laypage-em {
            background-color: #1E9FFF;
        }

        .btn-primary {
            color: #ffffff;
            background-color: #428bca !important;
            border-color: #357ebd !important;
        }
        .layui-laypage{
            margin-left: 4%;
        }
    </style>
</head>

<body ng-app="myApp" ng-controller="organizeCtrl">
<div class="content" id="organizeApp">
    <div style="padding: 10px 0;">系统管理>组织管理</div>
    <ul id="myTab" class="nav nav-pills">
        <li class="active">
            <a href="#organize" data-toggle="tab">组织机构</a>
        </li>
        <li>
            <a href="#userMang" data-toggle="tab">用户管理</a>
        </li>
        <li>
            <a href="#jobRole" data-toggle="tab">岗位角色</a>
        </li>
        <li>
            <a href="#authorityMang" data-toggle="tab">权限管理</a>
        </li>
    </ul>
    <div id="myTabContent" class="tab-content">
        <div class="tab-pane fade in active" id="organize">
            <div>
                <div class="dictory">
                    <div class="title">组织结构树</div>
                    <div class="demo-content">
                        <div>
                            <div id="t1"></div>
                        </div>
                    </div>
                </div>
                <div class="showDictory">
                    <div class="operationBtn row">
                        <div class="pull-right">
                            <button class="btn btn-primary" ng-click="addDept()">添加</button>
                            <button class="btn btn-primary" ng-click="deleteDept()">批量删除</button>
                        </div>
                    </div>
                    <div class="showDetail row">
                        <div id="table" class="table-content">
                            <table class="col-sm-12 table table-striped">
                                <thead>
                                <tr>
                                    <th width="5%">
                                        <input type="checkbox">
                                    </th>
                                    <th width="20%">部门名称</th>
                                    <th width="15%">机构代码</th>
                                    <th width="15%">描述</th>
                                    <th width="15%">上级部门</th>
                                    <th width="15%">用户数</th>
                                    <th width="10%">操作</th>
                                </tr>
                                </thead>
                                <tbody>

                                <tr ng-repeat="item in dataList1">
                                    <td><input type="checkbox" value="{$ item.id $}" name="org_id"></input></td>
                                    <td>{$ item.org_name $}</td>
                                    <td>{$ item.org_code $}</td>
                                    <td>{$ item.org_dec $}</td>
                                    <td>{$ item.parent_name $}</td>
                                    <td>{$ item.count $}</td>
                                    <td>
                                        <button class="btn btn-primary" ng-click="editDept(item.id)">编辑</button>
                                    </td>
                                </tr>

                                </tbody>
                            </table>
                        </div>
                        <div id="demo7" class="pag"></div>
                    </div>
                </div>
            </div>
        </div>
        <!--用户管理首页-->
        <div class="tab-pane fade" id="userMang">
            <div>
                <div class="dictory">
                    <div class="title">组织结构树</div>
                    <div class="demo-content">
                        <div>
                            <div id="t2"></div>
                        </div>
                    </div>
                </div>
                <div class="showDictory">
                    <div class="operationBtn row">
                        <div class="pull-right">
                            <button class="btn btn-primary" ng-click="addUser()">添加</button>
                            <button class="btn btn-primary" ng-click="deleteUser()">批量删除</button>
                        </div>
                    </div>
                    <div class="showDetail row">
                        <div id="table" class="table-content">
                            <table class="col-sm-12 table table-striped">
                                <thead>
                                <tr>
                                    <th width="3%">
                                        <input type="checkbox">
                                    </th>
                                    <th width="15%">账号</th>
                                    <th width="10%">姓名</th>
                                    <th width="15%">手机号</th>
                                    <th width="5%">性别</th>
                                    <th width="15%">部门</th>
                                    <th width="10%">岗位</th>
                                    <th width="5%">状态</th>
                                    <th width="15%">操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <tr ng-repeat="user in userList">
                                    <td><input type="checkbox" value="{$user.id$}" name="user_id"></td>
                                    <td ng-bind="user.username"></td>
                                    <td ng-bind="user.realname"></td>
                                    <td ng-bind="user.cloud_phone"></td>
                                    <td ng-if='user.cloud_sex==0?module.sex="男":module.sex="女";'
                                        ng-bind="module.sex"></td>
                                    <td ng-bind="user.org_name"></td>
                                    <td ng-bind="user.position_name"></td>
                                    <td ng-if='user.cloud_status==0?module.status="启用":module.status="禁用";'
                                        ng-bind="module.status"></td>
                                    <td>
                                        <button class="btn btn-primary" ng-click="editUser(user.id)">编辑</button>
                                        <button class="btn btn-primary" ng-click="deleteUserOnly(user.id)">刪除</button>
                                        <button class="btn btn-primary" ng-click="forgetUser(user.id)">忘记密码
                                        </button>
                                </tr>
                                </tbody>
                            </table>
                        </div>
                        <div id="userPage" class="pag"></div>
                    </div>
                </div>
            </div>
        </div>
        <!--岗位角色页面-->
        <div class="tab-pane fade" id="jobRole" style="background: #ffffff;height: 97%;">
            <div class="showJobList" style="height: 100%;">
                <div class="operationBtn row">
                    <div class="pull-right">
                        <button class="btn btn-primary" ng-click="addJob(0)">添加</button>
                        <button class="btn btn-primary" ng-click="deleteJob()">删除</button>
                    </div>
                </div>
                <div class="showDetail row" style="margin: 0px;height: 93%;">
                    <div id="jobTable" class="table-content" style="height: 91%;">
                        <table class="col-sm-12 table table-striped">
                            <thead>
                            <tr>
                                <th width="10%">
                                    <!--<input type="checkbox">-->
                                </th>
                                <th width="30%">岗位名称</th>
                                <th width="45%">岗位职责</th>
                                <th width="15%">操作</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr ng-repeat="job in jobList">
                                <td><input type="checkbox" value="{$ job.id $}" name="job_id"></td>
                                <td ng-bind="job.position_name"></td>
                                <td ng-bind="job.remarks"></td>
                                <td>
                                    <button class="btn btn-primary" ng-click="editJob(1,job.id)">编辑</button>
                                    <button class="btn btn-primary" ng-click="deleteUser(job.id)">刪除</button>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </div>
                    <div id="jobPage" class="pag"></div>
                </div>
            </div>
        </div>
        <div class="tab-pane fade" id="authorityMang">
            权限管理
        </div>
    </div>
</div>
<!--添加部门模态框  -->
<div class="modal fade" id="addModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    {$ modalTitle $}
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        <form role="form" class="form-horizontal">
                            <div class="form-group">
                                <label for="pDept" class="col-sm-2 control-label">上级部门</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="pDept" ng-model="deptForm.pDept"
                                           disabled="disabled">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="name" class="col-sm-2 control-label"><span style="color:#ff0000">*</span>部门名称</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="name" ng-model="deptForm.name"
                                           placeholder="请输入部门名称，不可多于30个字符" maxlength="30">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="code" class="col-sm-2 control-label"><span style="color:#ff0000">*</span>机构代码</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="code" ng-model="deptForm.code">
                                </div>
                            </div>
                            <input type="hidden" class="form-control" id="parent_id" ng-model="deptForm.parent_id">
                            <div class="form-group">
                                <label  class="col-sm-2 control-label">描述</label>
                                <div class="col-sm-10">
                      <textarea type="text" class="form-control"  ng-model="deptForm.description">
                      </textarea>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-primary" ng-click="addConfirmDept(deptForm)">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!--编辑部门模态框  -->
<div class="modal fade" id="editModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    {$ modalTitle $}
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        <form role="form" class="form-horizontal">
                            <div class="form-group">
                                <label for="pDept" class="col-sm-2 control-label">上级部门</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="pDept1" ng-model="deptForm.pDept"
                                           disabled="disabled">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="1" class="col-sm-2 control-label"><span style="color:#ff0000">*</span>部门名称</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="name1" ng-model="deptForm.name"
                                           placeholder="请输入部门名称，不可多于30个字符" maxlength="30">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="code" class="col-sm-2 control-label"><span style="color:#ff0000">*</span>机构代码</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="code1" ng-model="deptForm.code">
                                </div>
                            </div>
                            <input type="hidden" class="form-control" id="code2" ng-model="deptForm.parent_id">
                            <div class="form-group">
                                <label for="description" class="col-sm-2 control-label">描述</label>
                                <div class="col-sm-10">
                      <textarea type="text" class="form-control" id="description1" ng-model="deptForm.description">
                      </textarea>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" ng-click="editConfirmDept(deptForm)">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!-- 删除部门模态框 -->
<div class="modal fade" id="deleteModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    删除部门
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        部门删除不可恢复,是否确认删除?
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" ng-click="deleteConfirm(id)">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!--添加用户模态框-->
<div class="modal fade" id="addUser" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    {$ modalTitle $}
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        <form role="form" class="form-horizontal">
                            <div class="form-group">
                                <label for="firstName" class="col-sm-2 control-label">账户</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="firstName" ng-model="userForm.name"
                                           placeholder="请输入4-15个字符">
                                </div>
                                <label for="phoneNum" class="col-sm-2 control-label">手机</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="phoneNum" ng-model="userForm.phoneNum"
                                           placeholder="请输入您的手机号">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="pwd" class="col-sm-2 control-label"><span
                                        style="color:#ff0000">*</span>密码</label>
                                <div class="col-sm-4">
                                    <input type="password" class="form-control" id="pwd" ng-model="userForm.pwd"
                                           maxlength="30" placeholder="默认密码Qwert123456">
                                </div>
                                <label  class="col-sm-2 control-label"><span style="color:#ff0000">*</span>状态</label>
                                <div class="col-sm-4">
                                    <input type="radio" ng-value="0" ng-model="userForm.status" name="status">正常
                                    <input type="radio" ng-value="1" ng-model="userForm.status" name="status">禁用
                                </div>
                            </div>
                            <div class="form-group">
                                <label  class="col-sm-2 control-label">姓名</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control"  ng-model="userForm.firstName"
                                           placeholder="请输入2-15个字符">
                                </div>
                                <label for="gender" class="col-sm-2 control-label">性别</label>
                                <div class="col-sm-4">
                                    <input type="radio" ng-value="0" ng-model="userForm.gender" name="gerder">男
                                    <input type="radio" ng-value="1" ng-model="userForm.gender" name="gerder">女
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="department" class="col-sm-2 control-label"><span
                                        style="color:#ff0000">*</span>部门</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control"
                                           ng-value="1" ng-model="userForm.org_name" name="gerder" disabled>
                                </div>
                                <label for="position" class="col-sm-2 control-label"><span
                                        style="color:#ff0000">*</span>岗位</label>
                                <div class="col-sm-4">
                                    <select class="form-control" ng-model="userForm.position" name="type"
                                            ng-options="type.id as type.position_name for type in job_list">
                                        <option value="">请选择部门</option>
                                    </select>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" ng-click="addConfirmUser(userForm)">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!--编辑用户模态框-->
<div class="modal fade" id="editUser" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    {$ modalTitle $}
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        <form role="form" class="form-horizontal">
                            <div class="form-group">
                                <label for="firstName" class="col-sm-2 control-label">账户</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="firstName1" ng-model="userForm.firstName"
                                           placeholder="请输入4-15个字符">
                                </div>
                                <label for="phoneNum" class="col-sm-2 control-label">手机</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="phoneNum1" ng-model="userForm.phoneNum"
                                           placeholder="请输入您的手机号">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="pwd" class="col-sm-2 control-label"><span
                                        style="color:#ff0000">*</span>密码</label>
                                <div class="col-sm-4">
                                    <input type="password" class="form-control" id="pwd1" ng-model="userForm.pwd"
                                           maxlength="30" placeholder="默认密码000000">
                                </div>
                                <label for="name" class="col-sm-2 control-label"><span style="color:#ff0000">*</span>状态</label>
                                <div class="col-sm-4">
                                    <input type="radio" ng-value="0" ng-model="userForm.status" name="status">正常
                                    <input type="radio" ng-value="1" ng-model="userForm.status" name="status">禁用
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="name" class="col-sm-2 control-label">姓名</label>
                                <div class="col-sm-4">
                                    <input type="text" class="form-control" id="name2" ng-model="userForm.name"
                                           placeholder="请输入2-15个字符">
                                </div>
                                <label for="gender" class="col-sm-2 control-label">性别</label>
                                <div class="col-sm-4">
                                    <input type="radio" ng-value="0" ng-model="userForm.gender" name="gerder">男
                                    <input type="radio" ng-value="1" ng-model="userForm.gender" name="gerder">女
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="department" class="col-sm-2 control-label"><span
                                        style="color:#ff0000">*</span>部门</label>
                                <div class="col-sm-4">
                                    <input type="text" ng-click="chanceTree()" ng-model="userForm.org_name" name=""
                                           id="" value="" class="form-control"/>
                                </div>
                                <label for="position" class="col-sm-2 control-label"><span
                                        style="color:#ff0000">*</span>岗位</label>
                                <div class="col-sm-4">
                                    <select class="form-control" ng-model="userForm.position" name="type"
                                            ng-options="type.id as type.position_name for type in job_list">
                                        <option value="">请选择部门</option>
                                    </select>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" ng-click="editConfirmUser(userForm)">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!-- 删除用户模态框 -->
<div class="modal fade" id="deleteUser" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    删除用户
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        用户删除不可恢复,是否确认删除?
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" ng-click="deleteUserConfirm(id)">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!-- 删除单个用户模态框 -->
<div class="modal fade" id="deleteOnlyUser" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    删除用户
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        用户删除不可恢复,是否确认删除?
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" ng-click="deleteOnlyUserConfirm(id)">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<!--添加岗位模态框-->
<div class="modal fade" id="addJob" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    {$ modalTitle $}
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12">
                        <form role="form" class="form-horizontal">
                            <input type="hidden" name="addOrEdit" id="addOrEditJob" value=""/>
                            <div class="form-group">
                                <label for="postName" class="col-sm-2 control-label">岗位名称</label>
                                <div class="col-sm-10">
                                    <input type="text" class="form-control" id="postName" ng-model="jobForm.postName">
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="description" class="col-sm-2 control-label">职责描述</label>
                                <div class="col-sm-10">
											<textarea type="text" class="form-control" id="description"
                                                      ng-model="jobForm.description">
                      </textarea>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" ng-click="addConfirmJob(jobForm)">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>

<!--选择树模态框-->
<div class="modal fade" id="treeModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content" style="background-color: #EFF3FC;">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                </button>
                <h4 class="modal-title" id="myModalLabel">
                    {$ modalTitle $}
                </h4>
            </div>
            <div class="modal-body">
                <div class="row">
                    <div class="col-sm-12" id="t3">

                    </div>
                </div>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消
                </button>
                <button type="button" class="btn btn-primary" ng-click="addConfirmTree()">
                    确认
                </button>
            </div>
        </div>
    </div>
</div>
<script type="text/javascript" src="/static/assets/js/jquery.min.js"></script>
<script type="text/javascript" src="/static/bootstrap/js/bootstrap.min.js"></script>
<script type="text/javascript" src="/static/assets/js/bui-min.js"></script>
<script type="text/javascript" src="/static/assets/js/config-min.js"></script>
<script type="text/javascript" src="/static/assets/js/prettify.js"></script>
<script type="text/javascript" src="/static/plugins/angular/angular.min.js"></script>
<script type="text/javascript" src="/static/plugins/bui/seajs/2.3.0/sea.js"></script>
<script type="text/javascript" src="/static/plugins/bui/bui/1.1.21/config.js"></script>
<script type="text/javascript" src="/static/plugins/layui/js/layui.js"></script>
<script type="text/javascript">
    var app = angular.module('myApp', []);
    app.config(function ($interpolateProvider) {
        $interpolateProvider.startSymbol('{$');
        $interpolateProvider.endSymbol('$}');
    });
    app.controller('organizeCtrl', function ($scope, $http, $rootScope, $location, $timeout) {
        $scope.addDept = addDeptFunc; //添加部门
        $scope.editDept = editDeptFunc; //编辑部门
        $scope.deleteDept = deleteDeptFunc; //删除部门
        $scope.deleteUser = deleteUserFunc; //删除用户
        $scope.deleteUserOnly = deleteUserOnlyFunc; //删除单个用户
        $scope.addUser = addUserFunc;  //添加用户
        $scope.userForm = {
            firstName: "",
            phoneNum: "",
            pwd: "",
            status: "",
            name: "",
            gender: "",
            department: "",
            position: "",
            org_id: 0,
            org_name: "",
            id: 0,
        };
        $scope.deptForm = {
            id: 0,
            name: "",
            code: "",
            parent_id: 0,
            pDept: "",
            description: ""
        };
        $scope.jobForm = {
            postName: "",
            description: ""
        };
        $scope.userdept = {
            id: 0,
            org_name: ""
        };
        //组织机构列表数据
        var itemList = [];
        //获取树结构数据
        $scope.treeData = function () {
            $http.post('/orginazation/tree').then(
                function (resp) {
                    $scope.tree_data = resp.data.data;
                    $scope.showTree();
                },
                function (resp) {
                    alert("接口请求失败");
                });
        };
        $scope.treeData();
        //左侧组织结构导航树
        $scope.showTree = function () {
            $timeout(function () {
                BUI.use('bui/tree', function (Tree) {
                    var tree = new Tree.TreeList({
                        render: '#t1',
                        nodes: $scope.tree_data
                    });
                    var tree2 = new Tree.TreeList({
                        render: '#t2',
                        nodes: $scope.tree_data
                    });
                    tree.render();
                    tree2.render();
                    tree.on('itemclick', function (ev) {
                        var item = ev.item;
                        $('.log').text(item.level);
                        $scope.listData(item.id, item.level);
                        $scope.deptForm.parent_id = item.id;
                    });
                    tree2.on('itemclick', function (ev) {
                        var item = ev.item;
                        $scope.listUserData(item.id, item.level);
                        $scope.userForm.org_id = item.id;
                        $('.log').text(item.text);
                    });
                });
            }, 50);
        };
        {#编辑部门的模态框树#}
        $scope.chanceNewTree = function () {
            BUI.use('bui/tree', function (Tree) {
                var tree3 = new Tree.TreeList({
                    render: '#t3',
                    nodes: $scope.tree_data
                });
                tree3.render();
                tree3.on('itemclick', function (ev) {
                    var item = ev.item;
                    $scope.userdept.id = item.id;
                    $scope.userdept.org_name = item.text;
                    $('.log').text(item.text);
                });
            });
        }

        //获取列表
        $scope.listData = function (id, level) {
            var data = {level: level, org_id: id ? id : ""};
            $http({
                method: 'POST',
                url: '/api/orginazation/authorglist',
                data: data,
            }).success(function (res) {
                $scope.dataList = res.data;
                $scope.pageFun();
            });
            {% comment %} $http.post('/api/orginazation/orglist').then(
              function (resp) {
                  $scope.dataList = resp.data.data;
                  console.log("3333" + JSON.stringify(resp.data.data))
              },
              function (resp) {
                  alert("接口请求失败");
              });{% endcomment %}
        };
        $scope.listData();
        //分页
        var is_digest = 0;
        {#组织管理分页#}
        $scope.pageFun = function () {
            {#$timeout(function () {#}
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage
                    , layer = layui.layer;
                laypage.render({
                    elem: 'demo7'
                    , count: $scope.dataList.length
                    , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                    , jump: function (obj) {
                        $scope.dataList1 = $scope.dataList.slice((obj.curr - 1) * obj.limit, obj.curr * obj.limit);
                        $scope.$applyAsync();
                    }
                });

            });
            {% comment %} }, 100){% endcomment %}
        };
        {#用户列表分页#}
        $scope.userPageFun = function () {
            {#$timeout(function () {#}
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage
                    , layer = layui.layer;
                laypage.render({
                    elem: 'userPage'
                    , count: $scope.user_list.length
                    , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                    , jump: function (obj) {
                        $scope.userList = $scope.user_list.slice((obj.curr - 1) * obj.limit, obj.curr * obj.limit);
                        $scope.$applyAsync();
                    }
                });

            });
        };
        {#岗位分页#}
        $scope.jobPageFun = function () {
            {#$timeout(function () {#}
            layui.use(['laypage', 'layer'], function () {
                var laypage = layui.laypage
                    , layer = layui.layer;
                laypage.render({
                    elem: 'jobPage'
                    , count: $scope.job_list.length
                    , layout: ['count', 'prev', 'page', 'next', 'limit', 'skip']
                    , jump: function (obj) {
                        $scope.jobList = $scope.job_list.slice((obj.curr - 1) * obj.limit, obj.curr * obj.limit);
                        $scope.$applyAsync();
                    }
                });

            });
        };

        //添加部门
        function addDeptFunc() {
            $scope.modalTitle = "添加部门";
            $http({
                method: 'POST',
                url: '/orginazation/original',
                data: {"org_id": $scope.deptForm.parent_id},
            }).then(function successCallback(response) {
                $scope.deptForm.parent_id = response.data.data.id;
                $scope.deptForm.pDept = response.data.data.org_name;// == '-' ? "电信（陕西）云计算基地" : response.data.data.parent_code;
                //打开模态框
                $('#addModal').modal();
                // 请求成功执行代码
            }, function errorCallback(response) {
                // 请求失败执行代码
            });
        }

        //编辑部门
        function editDeptFunc(id) {
            $scope.modalTitle = "编辑部门";
            $http({
                method: 'POST',
                url: '/api/orginazation/orgedit',
                data: {"id": id},
            }).then(function successCallback(response) {
                $scope.deptForm.id = response.data.data.id;
                $scope.deptForm.pDept = response.data.data.parent_name;// == '-' ? "-" : "电信（陕西）云计算基地";
                $scope.deptForm.name = response.data.data.org_name;
                $scope.deptForm.code = response.data.data.org_code;
                $scope.deptForm.description = response.data.data.org_dec;
                $scope.deptForm.parent_id = response.data.data.parent_id;
                //打开模态框
                $('#editModal').modal();
                // 请求成功执行代码
            }, function errorCallback(response) {
                // 请求失败执行代码
            });
        }

        //删除部门
        function deleteDeptFunc() {
            $('#deleteModal').modal();
            // 确认删除部门
            $scope.deleteConfirm = function () {
                obj = document.getElementsByName("org_id");
                check_val = [];
                for (k in obj) {
                    if (obj[k].checked)
                        check_val.push(obj[k].value);
                }
                $http({
                    method: 'POST',
                    url: 'http://127.0.0.1:8000/api/orginazation/orgdelete',
                    data: {"id": check_val},
                }).then(function successCallback(response) {
                    console.log("删除成功");
                    // 请求成功执行代码
                }, function errorCallback(response) {
                    console.log("删除失败");
                    // 请求失败执行代码
                });
                $('#deleteModal').modal('hide');
            };
        }

        //删除用户
        function deleteUserFunc() {
            $('#deleteUser').modal();
            // 确认删除部门
            $scope.deleteUserConfirm = function () {
                obj = document.getElementsByName("user_id");
                check_val = [];
                for (k in obj) {
                    if (obj[k].checked)
                        check_val.push(obj[k].value);
                }
                $http({
                    method: 'POST',
                    url: 'http://127.0.0.1:8000/api/orginazation/authordelete',
                    data: {"id": check_val},
                }).then(function successCallback(response) {
                    console.log("删除成功");
                    // 请求成功执行代码
                }, function errorCallback(response) {
                    console.log("删除失败");
                    // 请求失败执行代码
                });
                $('#deleteUser').modal('hide');
            };
        }

        //删除单个用户
        function deleteUserOnlyFunc(id) {
            $('#deleteOnlyUser').modal();
            // 确认删除部门
            $scope.deleteOnlyUserConfirm = function () {
                $http({
                    method: 'POST',
                    url: 'http://127.0.0.1:8000/api/orginazation/authordelete',
                    data: {"id": [""+id,]},
                }).then(function successCallback(response) {
                    console.log("删除成功");
                    // 请求成功执行代码
                }, function errorCallback(response) {
                    console.log("删除失败");
                    // 请求失败执行代码
                });
                $('#deleteOnlyUser').modal('hide');
            };
        }

        //添加部门确认按钮
        $scope.addConfirmDept = function (form) {
            $('#addModal').modal('hide');
            //发送请求保存数据
            $http.post('/api/orginazation/orgadd', form).then(
                function (resp) {
                    console.log("添加成功");
                    $scope.treeData();
                    $("#t1").html("");
                    $("#t2").html("");
                    {#$scope.showTree();#}
                    {#window.location.reload();#}
                },
                function (resp) {
                    alert("接口请求失败");
                });
        };

        //编辑部门确认按钮
        $scope.editConfirmDept = function (form) {
            $('#editModal').modal('hide');
            //发送请求保存数据
            $http.post('/api/orginazation/orgupdate', form).then(
                function (resp) {
                    console.log("更新成功")
                },
                function (resp) {
                    alert("接口请求失败");
                });
        };

        //获取用户列表
        $scope.listUserData = function (id, level) {
            var data = {level: level, org_id: id ? id : 0};
            $http({
                method: 'POST',
                url: '/api/orginazation/authorlist',
                data: data
            }).then(
                function (resp) {
                    $scope.user_list = resp.data.data.user_list;
                    $scope.userPageFun();
                },
                function (resp) {
                    alert("接口请求失败");
                });
        };
        $scope.listUserData();

        //获取岗位列表
        $scope.listJobData = function () {
            $http({
                method: 'POST',
                url: '/api/orginazation/positionlist',
            }).then(
                function (resp) {
                    $scope.job_list = resp.data.data;
                    //$scope.job_list = resp.data.data;
                    $scope.jobPageFun();
                },
                function (resp) {
                    alert("接口请求失败");
                });
        };
        $scope.listJobData();

        //添加用户
        function addUserFunc() {
            $scope.modalTitle = "添加用户";
            $http({
                method: 'POST',
                url: '/orginazation/authoriginal',
                data: {"org_id": $scope.userForm.org_id},
            }).then(function successCallback(response) {
                $scope.userForm.org_id = response.data.data.id;
                $scope.userForm.org_name = response.data.data.org_name;// == '-' ? "电信（陕西）云计算基地" : response.data.data.parent_code;
                //打开模态框
                $('#addUser').modal();
                // 请求成功执行代码
            }, function errorCallback(response) {
                // 请求失败执行代码
            });
        }

        //编辑用户按钮
        $scope.editUser = function (id) {
            $scope.modalTitle = "编辑用户";
            $http({
                method: 'POST',
                url: '/api/orginazation/authoredit',
                data: {"id": id},
            }).then(function successCallback(response) {
                if (response.data.success == 0) {
                    alert("获取信息失败");
                    return;
                }
                $scope.userForm = response.data.data;
                $scope.userForm.position = $scope.userForm.position;
                //打开模态框
                $('#editUser').modal();
                // 请求成功执行代码
            }, function errorCallback(response) {
                // 请求失败执行代码
            });
        };
        //添加用户确认按钮
        $scope.addConfirmUser = function (form) {
            $('#addUser').modal('hide');
            //发送请求保存数据
            $http.post('/api/orginazation/authoradd', form).then(
                function (resp) {
                    console.log("添加成功");
                    $scope.treeData();
                    $scope.listUserData();
                    $("#t1").html("");
                    $("#t2").html("");
                },
                function (resp) {
                    alert("接口请求失败");
                });
        };
        //编辑用户确认按钮
        $scope.editConfirmUser = function (form) {
            $('#editUser').modal('hide');
            //发送请求保存数据
            $http.post('/api/orginazation/authorupdate', form).then(
                function (resp) {
                    console.log("添加成功");
                    $scope.treeData();
                    $scope.listUserData();
                    $("#t2").html("");
                    $("#t1").html("");
                    $scope.userForm.pwd = "";
                },
                function (resp) {
                    alert("接口请求失败");
                });
        };
        //添加岗位角色弹出模态框
        $scope.addJob = function (id) {
            $scope.modalTitle = "添加岗位角色";
            $scope.jobForm = {
                postName: "",
                description: ""
            };
            $("#addOrEditJob").val(id);
            $('#addJob').modal();
        };
        //编辑岗位弹模态框
        $scope.editJob = function (id, job_id) {
            $scope.modalTitle = "编辑岗位角色";
            $("#addOrEditJob").val(id);
            $http({
                method: 'POST',
                url: '/api/orginazation/positionedit',
                data: {"id": job_id},
            }).then(function successCallback(response) {
                if (response.data.success == 0) {
                    alert("获取信息失败");
                    return;
                }
                $scope.jobForm = response.data.data;
                //打开模态框
                $('#addJob').modal();
                // 请求成功执行代码
            }, function errorCallback(response) {
                // 请求失败执行代码
            });
        };
        //添加/编辑岗位角色确认事件
        $scope.addConfirmJob = function (form) {
            $('#addJob').modal('hide');
            var jobModalVal = $("#addOrEditJob").val();
            if (jobModalVal == 0) {
                //添加确定
                $http.post('/api/orginazation/positionadd', form).then(
                    function (resp) {
                        console.log("添加成功");
                        $scope.listJobData();
                    },
                    function (resp) {
                        alert("接口请求失败");
                    });
            } else {
                //编辑确定
                $http.post('/api/orginazation/positionupdate', form).then(
                    function (resp) {
                        console.log("更新成功");
                        $scope.listJobData();
                    },
                    function (resp) {
                        alert("接口请求失败");
                    });
            }
        }

        //部门选项出现树结构
        $scope.chanceTree = function () {
            $scope.modalTitle = "编辑部门";
            $("#t3").html("");
            $('#treeModal').modal();
            $scope.chanceNewTree();
        };
        //部门选项确定
        $scope.addConfirmTree = function () {
            $('#treeModal').modal("hide");
            $scope.userForm.org_id = $scope.userdept.id;
            $scope.userForm.org_name = $scope.userdept.org_name;
        }
    });
</script>
</body>
</html>